<template>
  <div>
    <van-nav-bar
      title="订单详情"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-contact-card
      type="edit"
      :name="contact.name"
      :tel="contact.tel"
    />
    <div class="content">
      <van-card
        v-for="item in list"
        :key="item.id"
        :num="item.num"
        :price="item.price"
        :title="item.name"
        :thumb="item.imgs.split('||')[0]"
      />
    </div>
    <div style="font-size:14px;margin:10px 0 0 10px">
      创建时间:{{time|date}}
    </div>
  </div>
</template>

<script>
import { getOneOrderDeatil } from '@api/home'
export default {
  name: 'orderlistdetail',
  data () {
    return {
      list: [
      ],
      time: '',
      contact: {
        tel: '',
        name: ''
      }
    }
  },
  filters: {
    date (val) {
      var d = new Date(val)
      var m = d.getMinutes()
      var s = d.getSeconds()
      m = checkTime(m)
      s = checkTime(s)

      function checkTime (i) {
        if (i < 10) {
          i = '0' + i
        }
        return i
      }
      return (
        d.getFullYear() +
        '年' +
        (d.getMonth() + 1) +
        '月' +
        d.getDate() +
        '日' +
        d.getHours() +
        '时' +
        m +
        '分' +
        s + '秒'
      )
    }
  },
  created () {
    this.init()
  },
  methods: {
    onClickLeft () {
      this.$router.go(-1)
    },
    init () {
      getOneOrderDeatil(this.$route.query.id).then(res => {
        if (res.data.code === 200) {
          this.list = res.data.data.content
          this.contact = res.data.data.contact
          this.time = res.data.data.create_time
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
